package com.realgodo.site.web.user.constellation;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.realgodo.site.entity.dic.Constellation;
import com.realgodo.site.service.dic.ConstellationManager;
import com.realgodo.site.web.user.UserDefaultController;

@Result(name = "toindex", type = "redirect", location = "${base}/user/config/")
public class IndexController extends UserDefaultController {

	/** 星座 */
	private static final long serialVersionUID = 5172591595492354709L;
	@Autowired
	private ConstellationManager constellationManager;

	private List<Constellation> constellationFriendList;

	@Override
	public String execute() throws Exception {
		return list();
	}

	public String list() {
		constellationFriendList = constellationManager.getConstellations(super
				.getSpace().getId());
		return SUCCESS;
	}

	// ----------get/set--------//
	public List<Constellation> getConstellationFriendList() {
		if (constellationFriendList == null) {
			constellationFriendList = new ArrayList<Constellation>();
		}
		return constellationFriendList;
	}

	public Date getNow() {
		return new Date();
	}

}
